#include <iostream>
#include <vector>
using namespace std;

template<typename T>
int binary_search(vector<T> vector, T item);

int main(int argc, char const *argv[]){
    //initial my_vector
    int my_array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    int my_array_length = sizeof(my_array)/sizeof(my_array[0]);
    vector<int> my_vector(my_array, my_array + my_array_length); 
    
    cout << binary_search(my_vector, 5) << endl;
    cout << binary_search(my_vector, 15) << endl;
    return 0;
}

template<typename T>
int binary_search(vector<T> vector, T item){
    int low = 0, high = vector.size()-1;
    while(low <= high){
        int mid = (low + high)/2;
        T guess = vector[mid];
        if(guess == item)
            return mid;
        else if(guess > item)
            low = mid + 1;
        else if(guess < item)
            high = mid - 1;
    }
    return -1;
}
